package com.example.demo.service.Impl;

import com.example.demo.dao.IFfmana;
import com.example.demo.model.Ffmana;
import com.example.demo.service.IFfmanaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Administrator 张少婷
 */

@Service
public class FfmanaServiceImpl implements IFfmanaService {

    @Autowired
    private IFfmana ffmanaMapper;
    @Override
    public int insertFfmana(Ffmana ffmana){
        int ffmanaValue=0;

        Ffmana ffmana1=new Ffmana();
        ffmana1.setLbid(ffmana.getLbid());
        List<Ffmana> getF=ffmanaMapper.getAllFfmana(ffmana1);
        if(getF.size()>0){
            ffmanaValue=-1;

        }else{
            ffmanaValue=ffmanaMapper.insertFfmana(ffmana);
        }

        return ffmanaValue;
    }

    @Override
    public List<Ffmana> getAllFfmana(Ffmana ffmana) {


        return ffmanaMapper.getAllFfmana(ffmana);
    }

    @Override
    public int updateFfmana(Ffmana ffmana) {
        int ffmanaValues=0;
        if(ffmana.getLbid()!=0){
            ffmanaValues=ffmanaMapper.updateFfmana(ffmana);
        }
        return ffmanaValues;
    }

    @Override
    public int deleteFfmana(Ffmana ffmana) {
        int ffmanaValues=0;
        if(ffmana.getLbid()!=0)
        {
            //主键是否与其他表有关联

            ffmanaValues=ffmanaMapper.deleteFfmana(ffmana);
        }
        return ffmanaValues;
    }

    @Override
    public Ffmana getFfmana(Ffmana ffmana) {
        Ffmana ffmana1=new Ffmana();
        if(ffmana.getLbid()!=0){
            ffmana1=ffmanaMapper.getFfmana(ffmana);
        }
        return ffmana1;
    }

}
